---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
spec:
  selector:
    matchLabels:
      name: postgres
  template:
    metadata:
      labels:
        name: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:14-alpine@sha256:446abaf8831c54f57212c0ae52f5df84e69eeb2767e2376d07bed9c9742b1243
        ports:
        - containerPort: 5432
        env:
        - name: POSTGRES_DB
          value: pl
        - name: POSTGRES_USER
          valueFrom:
            secretKeyRef:
              key: PL_POSTGRES_USERNAME
              name: pl-db-secrets
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              key: PL_POSTGRES_PASSWORD
              name: pl-db-secrets
        volumeMounts:
        - mountPath: /var/lib/postgresql/data
          subPath: data
          name: postgres-pv-claim
      volumes:
      - name: postgres-pv-claim
        persistentVolumeClaim:
          claimName: postgres-pv-claim
